package com.taobao.pojo;

import java.lang.reflect.Field;

import org.eclipse.swt.graphics.Color;

/**
 * @author Liupeng
 * @version CreateTime:2010-12-29
 */
public class Task extends RowObject{

	private Color c1 = new Color(null, 177, 214, 254);
	private Color c2 = new Color(null, 92, 168, 252);
	private Color c3 = new Color(null, 255, 199, 172);
	private Color c4 = new Color(null, 255, 131, 70);
	private Color c5 = new Color(null, 199, 244, 248);
	private Color c6 = new Color(null, 132, 184, 50);

    private String no;
    private long id;
    private String name;
    private double publishPoint;
    private double price;
    private Equals equals;
    private String publishTime;
    private String receiveTime;
    private ConfirmTime confirmTime;
    private State state;

    private String smallUser;
    private String tbUrl;
    private String tbName;
    private String hpWord;
    private String qq;

    private Color bgColor;

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPublishPoint() {
        return publishPoint;
    }

    public void setPublishPoint(double publishPoint) {
        this.publishPoint = publishPoint;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public Equals getEquals() {
        return equals;
    }

    public void setEquals(Equals equals) {
        this.equals = equals;
    }

    public String getPublishTime() {
        return publishTime;
    }

    public void setPublishTime(String publishTime) {
        this.publishTime = publishTime;
    }

    public String getReceiveTime() {
        return receiveTime;
    }

    public void setReceiveTime(String receiveTime) {
        this.receiveTime = receiveTime;
    }

    public ConfirmTime getConfirmTime() {
        return confirmTime;
    }

    public void setConfirmTime(ConfirmTime confirmTime) {
        this.confirmTime = confirmTime;
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
        if (state.getState() == 2) {
            setBgColor(c1);
        } else if (state.getState() == 3) {
            setBgColor(c2);
        } else if (state.getState() == 4) {
            setBgColor(c3);
        } else if (state.getState() == 5) {
            setBgColor(c4);
        } else if (state.getState() == 6) {
            setBgColor(c5);
        } else if (state.getState() == 8) {
            setBgColor(c6);
        }
    }

    public String getSmallUser() {
        return smallUser;
    }

    public void setSmallUser(String smallUser) {
        this.smallUser = smallUser;
    }

    public String getTbUrl() {
        return tbUrl;
    }

    public void setTbUrl(String tbUrl) {
        this.tbUrl = tbUrl;
    }

    public String getTbName() {
        return tbName;
    }

    public void setTbName(String tbName) {
        this.tbName = tbName;
    }

    public String getHpWord() {
        return hpWord;
    }

    public void setHpWord(String hpWord) {
        this.hpWord = hpWord;
    }

    public String getQq() {
        return qq;
    }

    public void setQq(String qq) {
        this.qq = qq;
    }

    public String[] toStringArrayForRoomTable() {
        String[] task = new String[10];
        task[0] = "";
        task[1] = "";
        task[2] = getId() + "";
        task[3] = getPublishPoint() + "";
        task[4] = getName();
        task[5] = getPrice() + "";
        task[6] = getEquals().getLabel();
        task[7] = getPublishTime();
        task[8] = getConfirmTime().getLabel();
        task[9] = getState().getLabel();
        return task;
    }

    public Color getBgColor() {
        return bgColor;
    }

    public void setBgColor(Color bgColor) {
        this.bgColor = bgColor;
    }

	public Task clone() {
        Task task = new Task();

        Field[] odlFields = this.getClass().getDeclaredFields();
        Field[] fields = task.getClass().getDeclaredFields();
        for (int i = 0; i < fields.length; i++) {
            Field field = fields[i];
            field.setAccessible(true);
            for (int j = 0; j < odlFields.length; j++) {
                Field oldField = odlFields[i];
                oldField.setAccessible(true);
                if (oldField.getName().equals(field.getName())) {
                    try {
                        field.set(task, oldField.get(this));
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
        return task;
    }
}
